/**
 * 
 */
package me.myachievements.persistence;

import org.hibernate.SessionFactory;
import org.hibernate.classic.Session;

/**
 * @author besseym
 *
 */
public class GenericPersistenceManagerImpl implements GenericPersistenceManager {
	
	private SessionFactory sessionFactory;

	/**
	 * Constructor
	 */
	public GenericPersistenceManagerImpl() {
	}

	/* (non-Javadoc)
	 * @see me.myachievements.persistence.GenericPersistenceManager#load(java.lang.Class, java.lang.Long)
	 */
	@Override
	public <T> T read(Class<T> type, Long id) {
		return (T) getCurrentSession().get(type, id);
	}
	
	/**
	 * @return the current session
	 */
	public Session getCurrentSession() { 
		return sessionFactory.getCurrentSession(); 
	}

	/**
	 * @return the sessionFactory
	 */
	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	/**
	 * @param sessionFactory the sessionFactory to set
	 */
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

}
